import { IResponseType } from '@/api/common';
import { LoginRO, LoginVO, UserRegisterRO } from './auth';
import service from '@/utils/axios';

export const login = (data: LoginRO) => {
    return service<IResponseType<LoginVO>>({
        url: '/auth/login',
        method: 'post',
        data
    });
};

export const refreshToken = (refToken: string) => {
    return service<IResponseType<LoginVO>>({
        url: '/auth/refreshToken',
        method: 'post',
        params: {
            refreshToken: refToken
        }
    });
};

export const register = (data: UserRegisterRO) => {
    return service<IResponseType<LoginVO>>({
        url: '/auth/register',
        method: 'post',
        data
    });
};

export const logout = () => {
    return service<IResponseType<void>>({
        url: '/auth/logout',
        method: 'get'
    });
};
